home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / hunt100.zip / HUNT.ASP < prev    next >
Text File  |  1991-11-13  |  11KB  |  448 lines

  1. ; HUNT.ASP Copyright (C) 1991 by Larry McElderry
  2. ; The following should contain the name of the directory (with trailing \)
  3. ; where your .HNT or .NOT configuration files are located
  4. ; As is,  HUNT will look in the current directory.  Change this if you
  5. ; plan to keep your configuration files in a different directory.
  6.  
  7. string configdir = ""
  8. integer cnorm = 31 
  9. integer cerr  = 79
  10. integer cwin =  30
  11. ;************************************************************
  12. ;  These are the variable paramaters that can be set from the configuration file
  13. ;  Values are provided here to act as defaults.  The config file name is made
  14. ;  up from the capitalized letters of each variable name (note that the names
  15. ;  themselves are not case sensitive).  ie. rw = RingWait
  16.  
  17. integer RingWait = 5
  18. string ModemSet = ""
  19. string autoLOG = ""
  20. long lowSPD = 300L
  21. ;************************************************************
  22. ; these variables will be set to Procomm's configuration settings
  23. ; There's no point in giving them values here,  because they will
  24. ; be changed at startup.  They can,  however,  be changed by the
  25. ; configuration files
  26. integer ConnectWait
  27. string ModemInit
  28. ;************************************************************
  29.  
  30. ; the following are the nine numbers that will be dialed
  31. ; config file parms n1 through n9
  32. string no1 = ""
  33. string no2 = ""
  34. string no3 = ""
  35. string no4 = ""
  36. string no5 = ""
  37. string no6 = ""
  38. string no7 = ""
  39. string no8 = ""
  40. string no9 = ""
  41. ;** don't mess with these variables
  42. string PCdial
  43. string PCsufx
  44. integer PCauto
  45. integer tooslow = 0
  46. integer ln = 0
  47. integer pos = 2
  48.  
  49. proc main
  50.     clear
  51.     kflush
  52.     set keys on
  53.     locate 0 0
  54.     atsay ln pos cnorm "HUNT.ASP Copyright (C) 1991 by Larry McElderry"
  55.     call pg
  56.     if not fromddir
  57.        atsay 21 pos cerr "ERROR:  this script must be called from the dialing directory"
  58.        exit
  59.     endif
  60.     call config
  61.     locate 21 0
  62.     transmit "ATE0^M"
  63.     waitfor "OK" 10
  64.     if not waitfor
  65.        atsay 21 pos cerr "ERROR:  modem did not respond to Local Echo Off command"
  66.        exit
  67.     endif
  68.     box 8 10 15 70 cwin
  69.     while forever
  70.         if not null no1
  71.            call dodial with no1
  72.            if connected
  73.               exitwhile
  74.            endif
  75.         endif
  76.         if not null no2
  77.            call dodial with no2
  78.            if connected
  79.               exitwhile
  80.            endif
  81.         endif
  82.         if not null no3
  83.            call dodial with no3
  84.            if connected
  85.               exitwhile
  86.            endif
  87.         endif
  88.         if not null no4
  89.            call dodial with no4
  90.            if connected
  91.               exitwhile
  92.            endif
  93.         endif
  94.         if not null no5
  95.            call dodial with no5
  96.            if connected
  97.               exitwhile
  98.            endif
  99.         endif
  100.         if not null no6
  101.            call dodial with no6
  102.            if connected
  103.               exitwhile
  104.            endif
  105.         endif
  106.         if not null no7
  107.            call dodial with no7
  108.            if connected
  109.               exitwhile
  110.            endif
  111.         endif
  112.         if not null no8
  113.            call dodial with no8
  114.            if connected
  115.               exitwhile
  116.            endif
  117.         endif
  118.         if not null no9
  119.            call dodial with no9
  120.            if connected
  121.               exitwhile
  122.            endif
  123.         endif
  124.     endwhile
  125.     set keys off
  126. endproc
  127.  
  128. proc dodial
  129.   strparm nv
  130.   string response
  131.   integer rings = 0
  132.  
  133.     hangup
  134.     fatsay 9 12 cwin "Calling %s at %s" $D_NAME nv
  135.     fatsay 10 12 cwin "Will wait for %d rings" RingWait
  136.     fatsay 11 12 cwin "connect script: %s" $D_PHONE
  137.     rflush
  138.     locate 21 0
  139.     if hitkey
  140.        call dokey
  141.     endif
  142.     transmit PCdial
  143.     transmit nv
  144.     transmit PCsufx
  145.  ringin:
  146.     locate 21 0
  147.     rget response 80 ConnectWait
  148.     if failure
  149.        call showstat with "Timed out"
  150.        return
  151.     endif
  152.     rget response
  153.     if hitkey
  154.        call dokey
  155.     endif
  156.     find response "CONNECT"
  157.     if found
  158.        call doconnect with nv response
  159.        hangup
  160.        return
  161.     endif
  162.     find response "RINGING"
  163.     if found
  164.        rings = rings + 1
  165.        rflush
  166.        strfmt response "Ring number %d" rings
  167.        call showstat with response
  168.        if gt rings RingWait
  169.           hangup
  170.           return
  171.        endif
  172.        goto ringin
  173.     endif
  174.     call showstat with response
  175. endproc
  176.  
  177. proc showstat
  178.   strparm msg
  179.   string msg2
  180.   integer lfc
  181.  
  182.     strpeek msg 0 lfc
  183.     if EQ lfc 10
  184.        substr msg2 msg 1 30
  185.     else
  186.        substr msg2 msg 0 30
  187.     endif
  188.     fatsay 14 12 cwin "Last Stat: %-20s" msg2
  189. endproc
  190.  
  191. proc dokey
  192.   integer k
  193.      keyget k
  194.      hangup
  195.      kflush
  196.      if EQ k 32
  197.         call showstat with "Recycle"
  198.         return
  199.      else
  200.         call showstat with "Key press abort"
  201.         exit
  202.      endif
  203. endproc
  204.  
  205. proc doconnect
  206.      strparm nv
  207.      strparm conmess
  208.      string msg2
  209.      integer lfc
  210.  
  211.      tooslow = 0
  212.      strpeek conmess 0 lfc
  213.      if EQ lfc 10
  214.         substr msg2 conmess 1 38
  215.      else
  216.         substr msg2 conmess 0 38
  217.      endif
  218.      find msg2 "14400"
  219.      if not found
  220.         find msg2 "9600"
  221.         if not found
  222.            find msg2 "2400"
  223.            if not found
  224.               find msg2 "1200"
  225.               if found
  226.                  call speedchk with 1200L
  227.               else
  228.                  call speedchk with $D_BAUD
  229.               endif
  230.            else
  231.               call speedchk with 2400L
  232.            endif
  233.         else
  234.            call speedchk with 9600L
  235.         endif
  236.      else
  237.         call speedchk with 19200L
  238.      endif
  239.      if tooslow
  240.         return
  241.      endif
  242.      clear
  243.      atsay 0 0 cnorm msg2
  244.      fatsay 1 0 cnorm "Online to %s at %s" $D_NAME nv
  245.      locate 2 0
  246.      alarm
  247.      if not null autoLOG
  248.         log open autoLOG
  249.      endif
  250.      if not null $D_PHONE
  251.         execute $D_PHONE
  252.      else
  253.         exit
  254.      endif
  255. endproc
  256.  
  257. proc speedchk
  258.    longparm spd
  259.  
  260.    if LT spd lowSPD
  261.       call showstat with "Too slow!!!"
  262.       tooslow = 1
  263.       return
  264.    endif
  265.    if PCauto
  266.       set baudrate spd
  267.    endif
  268. endproc
  269.  
  270. proc config
  271.   string ConfigFile = configdir
  272.  
  273.     atsay ln pos cnorm "Initializing"
  274.     call pg
  275.     ;*** set default values
  276.     fetch modem dialcmnd PCdial
  277.     fetch modem dialsuffix PCsufx
  278.     fetch modem init ModemInit
  279.     fetch modem waitcnct ConnectWait
  280.     fetch modem autobaud PCauto
  281.     if not null $D_NOTE
  282.        strcat ConfigFile $D_NOTE
  283.        strcat ConfigFile ".HNT"
  284.        findfirst ConfigFile
  285.        if found
  286.           call Fconfig with ConfigFile
  287.        else
  288.           ConfigFile = configdir
  289.           strcat ConfigFile $D_NOTE
  290.           strcat ConfigFile ".NOT"
  291.           findfirst ConfigFile
  292.           if found
  293.              call Fconfig with ConfigFile
  294.           else
  295.              ConfigFile = ""
  296.           endif
  297.        endif
  298.     else
  299.        atsay 21 pos cerr "ERROR: you must specify a configuration file in NOTE FILE:"
  300.        exit
  301.     endif
  302.     if null ConfigFile
  303.        atsay 21 pos cerr "ERROR: Unable to locate configuration file"
  304.        exit
  305.     endif
  306.     if null no1
  307.        if null no2
  308.           if null no3
  309.              if null no4
  310.                 if null no5
  311.                    if null no6
  312.                       if null no7
  313.                          if null no8
  314.                             if null no9
  315.                                atsay 21 pos cerr "ERROR: no phone numbers found"
  316.                                exit
  317.                             endif
  318.                          endif
  319.                       endif
  320.                    endif
  321.                 endif
  322.              endif
  323.           endif
  324.        endif
  325.     endif
  326.     call initmodem
  327. endproc
  328.  
  329. proc Fconfig
  330.   strparm cfile
  331.   string fl
  332.   string fl1
  333.   string fl2
  334.   integer num
  335.  
  336.   Fatsay ln pos cnorm "Reading configuration file %s" cfile
  337.   call pg
  338.   set fgets_crlf off
  339.   fopen 0 cfile "rt"
  340.   if success
  341.      locate ln 0
  342.      fgets 0 fl
  343.      message fl
  344.      call pg
  345.      find fl "#HUNT"
  346.      if found
  347.         while not EOF 0
  348.            fgets 0 fl
  349.            message fl
  350.            call pg
  351.            strpeek fl 1 num
  352.            if EQ num 35
  353.               loopwhile
  354.            endif
  355.            substr fl1 fl 0 3
  356.            substr fl2 fl 4 80
  357.            strlwr fl1
  358.            switch fl1
  359.               case "n1 "
  360.                 no1 = fl2
  361.               endcase
  362.               case "n2 "
  363.                 no2 = fl2
  364.               endcase
  365.               case "n3 "
  366.                 no3 = fl2
  367.               endcase
  368.               case "n4 "
  369.                 no4 = fl2
  370.               endcase
  371.               case "n5 "
  372.                 no5 = fl2
  373.               endcase
  374.               case "n6 "
  375.                 no6 = fl2
  376.               endcase
  377.               case "n7 "
  378.                 no7 = fl2
  379.               endcase
  380.               case "n8 "
  381.                 no8 = fl2
  382.               endcase
  383.               case "n9 "
  384.                 no9 = fl2
  385.               endcase
  386.               case "mi "
  387.                 ModemInit = fl2
  388.               endcase
  389.               case "ms "
  390.                 ModemSet = fl2
  391.               endcase
  392.               case "rw "
  393.                 atoi fl2 RingWait
  394.               endcase
  395.               case "cw "
  396.                 atoi fl2 ConnectWait
  397.               endcase
  398.               case "spd"
  399.                 atol fl2 lowSPD
  400.               endcase
  401.               case "log"
  402.                 autoLOG = fl2
  403.               endcase
  404.               case "end"
  405.                 exitwhile
  406.               endcase
  407.            endswitch
  408.         endwhile
  409.      else
  410.         fatsay ln pos cerr "%s is not a valid HUNT configuration file" cfile
  411.         exit
  412.      endif
  413.      fclose 0
  414.   endif
  415. endproc
  416.  
  417. proc initmodem
  418.  
  419.     locate 21 0
  420.     if not null ModemInit
  421.       find ModemInit PCsufx
  422.       if not found
  423.          strcat ModemInit PCsufx
  424.       endif
  425.       transmit ModemInit
  426.       waitfor "OK" 30
  427.       pause 1
  428.     endif
  429.     locate 21 0
  430.     if not null ModemSet
  431.       find ModemSet PCsufx
  432.       if not found
  433.          strcat ModemSet PCsufx
  434.       endif
  435.       transmit ModemSet
  436.       waitfor "OK" 10
  437.     endif
  438. endproc
  439.  
  440. proc pg
  441.     inc ln
  442.     if EQ ln 24
  443.        ln = 2
  444.        locate 2 0
  445.        eeos
  446.     endif
  447. endproc
  448.